package cn.flant.cmd;

import java.net.InetAddress;

import cn.flant.io.tcp.SocketHandler;

public class AclProcessor extends FilterAdapter {
	private String ipAddr1 = "192.168.1.101";
	private String ipAddr2 = "127.0.0.1";

	@Override
	public void onConnected(SocketHandler socketHandler) throws Exception {
		InetAddress address = socketHandler.getRemoteAddress();
		boolean result = address.isLoopbackAddress() || address.isLinkLocalAddress() || address.isAnyLocalAddress();
		if (!result) {
			String remote = address.getHostAddress();
			result = ipAddr1.equals(remote) || ipAddr2.equals(remote);
		}
		if (!result) {
			socketHandler.destroy();
		}
	}
}
